<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="CompleteSprint.aspx.cs" Inherits="CompleteSprint" Title="Tackle - Complete Sprint" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHolder" runat="Server">
    <strong>Complete Sprint<br />
    </strong><span style="font-size: 8pt">
        <br />
        Select an action item for each feature from the sprint shown below.<br />
        <br />
        <asp:UpdatePanel runat="server" ID="UPGridView" UpdateMode="Conditional">
            <ContentTemplate>
                <table cellpadding="4" cellspacing="0" style="width: 98%">
                    <tr>
                        <td bgcolor="#e3eaeb" style="border-right: silver 1px ridge; border-top: silver 1px ridge;
                            border-left: silver 1px ridge; border-bottom: silver 1px ridge" valign="top">
                            <span style="font-size: 10pt"><span style="font-size: x-small">Sprint:</span> </span>
                            <asp:DropDownList ID="ddSprintSelection" runat="server" AutoPostBack="True" DataSourceID="dsGetSprintNames"
                                DataTextField="SprintName" DataValueField="SprintID" Font-Size="X-Small" OnDataBound="ddSprintSelection_DataBound" OnSelectedIndexChanged="ddSprintSelection_SelectedIndexChanged">
                            </asp:DropDownList>
                            <em><span style="font-size: xx-small">(only sprints that are in the past are shown in
                                this list)</span></em></td>
                    </tr>
                    <tr>
                        <td>
                            <asp:GridView ID="gvCompleteSprint" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                                CellPadding="4" DataKeyNames="MasterBacklogID" DataSourceID="dsSprintBacklogItems"
                                Font-Names="Verdana" Font-Size="X-Small" ForeColor="#333333" GridLines="None"
                                OnRowDataBound="gvCompleteSprint_RowDataBound" OnPreRender="gvCompleteSprint_PreRender">
                                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                                <Columns>
                                    <asp:BoundField DataField="MasterBacklogID" HeaderText="ID" ReadOnly="True" SortExpression="MasterBacklogID">
                                        <ItemStyle VerticalAlign="Top" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="ProductName" HeaderText="Product" ReadOnly="True" SortExpression="ProductName">
                                        <ItemStyle VerticalAlign="Top" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="Feature" HeaderText="Feature" ReadOnly="True" SortExpression="Feature">
                                        <ItemStyle VerticalAlign="Top" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="Activity" HeaderText="Activity" SortExpression="Activity">
                                        <ItemStyle VerticalAlign="Top" />
                                    </asp:BoundField>
                                    <asp:TemplateField HeaderText="Description" SortExpression="Description">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                        <ItemStyle VerticalAlign="Top" />
                                        <ItemTemplate>
                                            <asp:Label ID="lbDescription" runat="server" OnPreRender="lbDescription_PreRender"
                                                Text='<%# Bind("Description") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Actual (Hours)" SortExpression="SumActualTime">
                                        <EditItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("SumActualTime") %>'></asp:Label>
                                        </EditItemTemplate>
                                        <ItemStyle VerticalAlign="Top" />
                                        <HeaderStyle Wrap="False" />
                                        <ItemTemplate>
                                            <asp:Label ID="lblActualHours" runat="server" Text='<%# Bind("SumActualTime", "{0:F}") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Punted (Hours)" SortExpression="SumPuntedTime">
                                        <EditItemTemplate>
                                            <asp:Label ID="Label2" runat="server" Text='<%# Eval("SumPuntedTime") %>'></asp:Label>
                                        </EditItemTemplate>
                                        <ItemStyle VerticalAlign="Top" />
                                        <HeaderStyle Wrap="False" />
                                        <ItemTemplate>
                                            <asp:Label ID="lblPuntedHours" runat="server" Text='<%# Bind("SumPuntedTime", "{0:F}") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Action">
                                        <ItemStyle VerticalAlign="Top" />
                                        <ItemTemplate>
                                            <asp:DropDownList ID="ddAction" runat="server" Font-Names="Verdana" Font-Size="X-Small">
                                                <asp:ListItem Value="0">Mark as Complete</asp:ListItem>
                                                <asp:ListItem Value="1">Create Feature from Punted / Mark as Complete</asp:ListItem>
                                                <asp:ListItem Value="2">Do Nothing</asp:ListItem>
                                            </asp:DropDownList>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <RowStyle BackColor="#E3EAEB" />
                                <EditRowStyle BackColor="#7C6F57" />
                                <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                                <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                                <AlternatingRowStyle BackColor="White" />
                            </asp:GridView>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Button ID="btnSubmit" runat="server" Font-Names="Verdana" Font-Size="X-Small"
                                OnClick="btnSubmit_Click" Text="Submit" OnClientClick="return confirm('This will commit all changes to the product features and is not undoable.\n\nAre you sure you want to submit these actions?');" />
                            <asp:Label ID="lblSubmitComplete" runat="server" Font-Bold="True" ForeColor="Red"
                                Text="The changes have been submitted successfully. The action drop downs have been reset to their calculated value."
                                Visible="False"></asp:Label></td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </span>
    <asp:SqlDataSource ID="dsGetSprintNames" runat="server" ConnectionString="<%$ ConnectionStrings:TackleConnectionStringMain %>"
        SelectCommand="SELECT tblSprint.SprintID, tblMasterBacklogSchedule.SprintName, tblMasterBacklogSchedule.MasterBacklogScheduleID FROM tblMasterBacklogSchedule INNER JOIN tblSprint ON tblMasterBacklogSchedule.MasterBacklogScheduleID = tblSprint.fMasterBacklogScheduleID WHERE (tblMasterBacklogSchedule.fScrumTeamID = @ScrumTeamID) AND (tblMasterBacklogSchedule.EndDate < GETDATE()) ORDER BY tblMasterBacklogSchedule.EndDate DESC"
        ProviderName="<%$ ConnectionStrings:TackleConnectionStringMain.ProviderName %>">
        <SelectParameters>
            <asp:SessionParameter Name="ScrumTeamID" SessionField="ScrumTeamID" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="dsSprintBacklogItems" runat="server" ConnectionString="<%$ ConnectionStrings:TackleConnectionStringMain %>"
        OldValuesParameterFormatString="original_{0}" ProviderName="<%$ ConnectionStrings:TackleConnectionStringMain.ProviderName %>"
        SelectCommand="SELECT TOP (100) PERCENT ISNULL(tblSprintBacklog.fMasterBacklogID, - 1) AS MasterBacklogID, ISNULL(tblProducts.ProductName, 'Discovered') AS ProductName, ISNULL(tblMasterBacklog.Feature, 'All') AS Feature, tblMasterBacklog.Activity, tblMasterBacklog.Description, SUM(tblSprintBacklog.ActualTimeTotal * @TimeMult) AS SumActualTime, dbo.CalculatePuntedTimeForFeature(tblSprintBacklog.fMasterBacklogID, @SprintID) * @TimeMult AS SumPuntedTime, tblMasterBacklog.FeatureComplete FROM tblProducts INNER JOIN tblMasterBacklog ON tblProducts.ProductID = tblMasterBacklog.fProductID RIGHT OUTER JOIN tblSprintBacklog ON tblMasterBacklog.MasterBacklogID = tblSprintBacklog.fMasterBacklogID WHERE (tblSprintBacklog.OOF = 0) GROUP BY tblSprintBacklog.fSprintID, tblMasterBacklog.Feature, tblSprintBacklog.fMasterBacklogID, tblProducts.ProductName, tblMasterBacklog.MasterRank, ISNULL(tblMasterBacklog.MasterRank, 1000000), tblMasterBacklog.Activity, tblMasterBacklog.Description, tblMasterBacklog.FeatureComplete HAVING (tblSprintBacklog.fSprintID = @SprintID) AND (ISNULL(tblProducts.ProductName, 'Discovered') <> 'Discovered') AND (tblMasterBacklog.FeatureComplete = 0) ORDER BY ProductName, tblMasterBacklog.MasterRank">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddSprintSelection" Name="SprintID" PropertyName="SelectedValue" />
            <asp:SessionParameter Name="TimeMult" SessionField="SBTimeMult" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
